﻿using System;
using System.Collections.Generic;
using System.Text;
using CoreWf;
using CoreWf.Statements;
using CoreWf.Expressions;

namespace netcoreWF
{
    public class MainActivity : Activity
    {
        public MainActivity(string inputs)
        {
            this.Implementation = () =>
            {
                Variable<string> inputsVar = new Variable<string> { Default = inputs };

                FlowStep hello = new FlowStep
                {
                    Action = new WriteLine
                    {
                        DisplayName = "WriteLine",
                        Text = new InArgument<string>(inputsVar)
                    },
                    Next = null
                };

                Flowchart flight = new Flowchart
                {
                    DisplayName = "flight flowchart",
                    StartNode = hello,
                    Nodes = { hello }
                };

                Flowchart safeguard = new Flowchart
                {
                    DisplayName = "safeguard flowchart"

                };

                Parallel parallel = new Parallel
                {
                    DisplayName = "alltasks",
                    Branches = { new FlightTaskActivity(), flight, safeguard }
                };

                FlowStep parallelStep = new FlowStep
                {
                    Action = parallel,
                    Next = null
                };

                Flowchart mainFlowchart = new Flowchart
                {
                    DisplayName = "main flowchart",
                    Variables = { inputsVar },
                    StartNode = parallelStep,
                    Nodes =
                {
                    parallelStep
                }
                };
                return mainFlowchart;
            };
        }
    }
}
